#pragma once
#include "IGameComponent.hpp"
#include <vector>
#include <algorithm>

namespace Typhoon {
	class Aspect
	{
	public:
		Aspect();
		Aspect(const Aspect& other);

		~Aspect();

		bool operator == (const Aspect& other) const;
		bool operator != (const Aspect& other) const;

		template<class T>
		void AddComponent();
		template<class T>
		void RemoveComponent();

		bool DoesSatisfy(const std::vector<IGameComponent*>& components) const;

	private:

		typedef std::vector<unsigned int> Components;
		Components components;
	};
}

template<class T>
void Typhoon::Aspect::AddComponent()
{
	components.push_back(T::GetIndex());
}

template<class T>
void Typhoon::Aspect::RemoveComponent()
{
	unsigned int index = T::GetIndex();
	Components::iterator it = std::find(components.begin(), components.end(), index);
	if (it==components.end()) return;
	components.erase(it);
}

